/**
 * 楼宇模型
 */
class Building extends CommonModels {
    tableFields() {
        return {
            "region_id":{
                "label": "辖区ID",
                "type": "int(11)"
            },
            "name":{
                "label": "楼宇名称",
                "type": "varchar(100)"
            },
            "status":{
                "label": "楼宇状态",
                "type": "int(1)"
            },
            "address":{
                "label": "所在地址",
                "type": "varchar(500)"
            },
            "total_area":{
                "label": "总面积",
                "type": "varchar(50)"
            },
            "business_area":{
                "label": "商务面积",
                "type": "varchar(50)"
            },
            "total_height":{
                "label": "总高度",
                "type": "varchar(50)"
            },
            "ground_height":{
                "label": "地上高度",
                "type": "varchar(50)"
            },
            "underground_height":{
                "label": "地下高度",
                "type": "varchar(50)"
            },
            "grounp_floor":{
                "label": "地上层数",
                "type": "int(5)"
            },
            "undergrounp_floor":{
                "label": "地下层数",
                "type": "int(5)"
            },
            "begin_time":{
                "label": "开工时间",
                "type": "datetime"
            },
            "over_time":{
                "label": "竣工时间",
                "type": "datetime"
            },
            "use_time":{
                "label": "投用时间",
                "type": "datetime"
            },
            "property_name":{
                "label": "物业公司",
                "type": "varchar(255)"
            },
            "property_contact":{
                "label": "物业联系人",
                "type": "varchar(50)"
            },
            "property_level":{
                "label": "物管等级",
                "type": "varchar(50)"
            },
            "property_cost":{
                "label": "物管费用",
                "type": "varchar(50)"
            },
            "property_phone":{
                "label": "物业联系方式",
                "type": "varchar(50)"
            },
            "carport_number":{
                "label": "车位数",
                "type": "int(10)"
            },
            "carport_cost":{
                "label": "车位租金",
                "type": "varchar(100)"
            },
            "note":{
                "label": "楼宇介绍",
                "type": "varchar(500)"
            }
        }
    }

    /**
     * 实现数据验证
     * 需要数据写入，必须在rules添加对应规则
     * 在控制中执行[模型]->attributes = $postData;
     * 否则会导致验证不生效，并且写入数据为空
     * @return [type] [description]
     */
    rules() {
        return {
            
        }
    }

    /**
     * 表名称
     * @returns {string}
     */
    tableName() {
        return '{{%building}}';
    }

    getRegion(){
        return this.belongsTo({name:M('Region').tableName(),as:'region_info'},'region_id', 'id',['id','province','city','area','street','province_name','city_name','area_name','street_name']);
    }

}

export default Building;